/*
 *  scoreBoard - OscDataReceiver.h
 *  Copyright 2011 W. Reckman. All rights reserved.
 */
#ifndef OSC_DATA_RECEIVER_H

#include <iostream>
#include <fstream>
#include "ofxOsc.h"
#include "BoardModel.h"

class Settings;
class ScoreBoardApp;


class OscDataReceiver {
public:
	static const string LOG_FILE_NAME;
	
	static const string OSC_ADDR_GAME_BALANCE;
	static const string OSC_ADDR_GAME_STATE_OLD;
	static const string OSC_ADDR_GAME_STATE_NEW;
	
	static const string OSC_ADDR_GAME_PLAYER_DATE;
	static const string OSC_ADDR_GAME_PLAYER_TIME;
	static const string OSC_ADDR_GAME_PLAYER_TARGETS;
	static const string OSC_ADDR_GAME_PLAYER_ID;
	static const string OSC_ADDR_GAME_PLAYER_IMAGES;
	static const string OSC_ADDR_GAME_PLAYER_COLOR;
	static const string OSC_ADDR_GAME_PLAYER_PICKUPS;
	
	OscDataReceiver( ScoreBoardApp& appRef_ );
	~OscDataReceiver();
	
	void setup();
	void update();
	
private:
	Settings& s;
	ScoreBoardApp& appRef;
	
	std::ofstream logFile;
	ofxOscReceiver oscReceiver;
	
	bool hasPrevState;
	GAME_STATE prevState;
	
	bool hasDate, hasTime, hasTargets, hasId, hasImages, hasColor, hasPickups;
	BoardModel::PlayerInfo infoTemp;
	
	void logBalanceChange( float balance_ );
	void logStateChange( GAME_STATE prevState_, GAME_STATE currState_ );
	void logPlayerStats( BoardModel::PlayerInfo info_ );
};

#define OSC_DATA_RECEIVER_H
#endif /* ! OSC_DATA_RECEIVER_H */
